trigger AASLockAccountByCollections on Case (before update) {
    list<account> acc = new list<account>() ;    
    list<account> accounts = new list<account>();
    //Map <String,Schema.RecordTypeInfo> recordTypes =  Case.sObjectType.getDescribe().getRecordTypeInfosByName();
    //Id AASCollectionsRecordTypeID = recordTypes.get('AAS Collections').getRecordTypeId();
    Id AASCollectionsRecordTypeID = RecordTypeHelper.GetRecordTypeIDByDevName('Case',  'AAS_Collections'); // please use RecordTypeHelper
    set<id> accids = new set<id>() ;
    set<id> LockedAccIds = new set<id>() ;
    
     for(Case C :trigger.new){
         if(C.Account_Collections_Status__c == 'Locked by Collections'&& C.recordtypeid == AASCollectionsRecordTypeID)
             LockedAccIds.add(C.accountid);
          else if(C.Account_Collections_Status__c != 'Locked by Collections'&& trigger.oldMap.get(C.id).Account_Collections_Status__c == 'Locked by Collections'&& C.recordtypeid == AASCollectionsRecordTypeID)       
             accids.add(C.accountid); 
     }
 
     if(LockedAccIds.size()>0 || accids.size()>0) acc = [select account_locked__c from account where id in :LockedAccIds or id in :accids]; 
    
     for(account A :acc){
         if(accids.contains(A.id)) 
             A.account_locked__c = false; 
         else      
             A.account_locked__c = true;
         accounts.add(A);
     }
     
     try{Update accounts;}
     Catch(dmlException e){
         system.debug('Trigger Name:AASLockAccountByCollections Action Failed:Could not Lock/Unlock Accounts by Collections' + e);
         GeneralConstants.mailAnyExceptionToMe('AASLockAccountByCollections', 'Update accounts fail', e);
     }
         

}